home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / cmds.fmt / expr.man < prev    next >
Encoding:
Text File  |  1989-10-04  |  2.7 KB  |  133 lines

  1.  
  2.  
  3.  
  4. EXPR                      User Commands                      EXPR
  5.  
  6.  
  7.  
  8. NNAAMMEE
  9.      expr - evaluate arguments as an expression
  10.  
  11. SSYYNNOOPPSSIISS
  12.      eexxpprr arg ......
  13.  
  14. DDEESSCCRRIIPPTTIIOONN
  15.      The arguments are taken as an expression.  After evaluation,
  16.      the result is written on the standard output.  Each token of
  17.      the expression is a separate argument.
  18.  
  19.      The operators and keywords are listed below.  The list is in
  20.      order of increasing precedence, with equal precedence opera-
  21.      tors grouped.
  22.  
  23.      _e_x_p_r | _e_x_p_r
  24.           yields the first _e_x_p_r if it is neither null nor `0',
  25.           otherwise yields the second _e_x_p_r.
  26.  
  27.      _e_x_p_r & _e_x_p_r
  28.           yields the first _e_x_p_r if neither _e_x_p_r is null or `0',
  29.           otherwise yields `0'.
  30.  
  31.      _e_x_p_r _r_e_l_o_p _e_x_p_r
  32.           where _r_e_l_o_p _i_s _o_n_e _o_f < <= = != >= >, yields `1' if the
  33.           indicated comparison is true, `0' if false.  The com-
  34.           parison is numeric if both _e_x_p_r are integers, otherwise
  35.           lexicographic.
  36.  
  37.      _e_x_p_r + _e_x_p_r
  38.      _e_x_p_r - _e_x_p_r
  39.           addition or subtraction of the arguments.
  40.  
  41.      _e_x_p_r * _e_x_p_r
  42.      _e_x_p_r / _e_x_p_r
  43.      _e_x_p_r % _e_x_p_r
  44.           multiplication, division, or remainder of the argu-
  45.           ments.
  46.  
  47.      _e_x_p_r : _e_x_p_r
  48.           The matching operator compares the string first argu-
  49.           ment with the regular expression second argument; regu-
  50.           lar expression syntax is the same as that of _e_d(1).
  51.           The \\((......\\)) pattern symbols can be used to select a
  52.           portion of the first argument.  Otherwise, the matching
  53.           operator yields the number of characters matched (`0'
  54.           on failure).
  55.  
  56.      ( _e_x_p_r )
  57.           parentheses for grouping.
  58.  
  59.      Examples:
  60.  
  61.  
  62.  
  63. Sprite v1.0              April 29, 1985                         1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. EXPR                      User Commands                      EXPR
  71.  
  72.  
  73.  
  74.      To add 1 to the Shell variable _a:
  75.  
  76.           a=`expr $a + 1`
  77.  
  78.      To find the filename part (least significant part) of the
  79.      pathname stored in variable _a, which may or may not contain
  80.      `/':
  81.  
  82.           expr $a : '.*/\(.*\)' '|' $a
  83.  
  84.      Note the quoted Shell metacharacters.
  85.  
  86. SSEEEE AALLSSOO
  87.      sh(1), test(1)
  88.  
  89. DDIIAAGGNNOOSSTTIICCSS
  90.      _E_x_p_r returns the following exit codes:
  91.  
  92.           0    if the expression is neither null nor `0',
  93.           1    if the expression is null or `0',
  94.           2    for invalid expressions.
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129. Sprite v1.0              April 29, 1985                         2
  130.  
  131.  
  132.  
  133.